﻿namespace Smart.Utils.Lib
{
    using Microsoft.VisualBasic;
    using Smart.Utils.App;
    using System;
    using System.Data;
    using System.Globalization;
    using System.Net.NetworkInformation;
    using System.Text.RegularExpressions;
    using System.Windows.Forms;

    public static class MyLib
    {
        private static string _Currency = "VND";
        private static string _currencySymbol = "đồng";
        private static string _UnitSecond = "";

        public static void AddCalender(DataGridView dt, string ColumnName)
        {
            DataGridViewCalendarColumn dataGridViewColumn = new DataGridViewCalendarColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddCalender(DataGridView dt, string ColumnName, string Caption)
        {
            DataGridViewCalendarColumn dataGridViewColumn = new DataGridViewCalendarColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddCalender(DataGridView dt, string ColumnName, string Caption, bool ReadOnly)
        {
            DataGridViewCalendarColumn dataGridViewColumn = new DataGridViewCalendarColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.ReadOnly = ReadOnly;
            dataGridViewColumn.ValueType = typeof(DateTime);
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddCalender(DataGridView dt, string ColumnName, string Caption, bool ReadOnly, string Format)
        {
            DataGridViewCalendarColumn dataGridViewColumn = new DataGridViewCalendarColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.ReadOnly = ReadOnly;
            dataGridViewColumn.DefaultCellStyle.Format = Format;
            dataGridViewColumn.ValueType = typeof(DateTime);
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddCalender(DataGridView dt, string ColumnName, string Caption, bool ReadOnly, string Format, DataGridViewContentAlignment Aligment)
        {
            DataGridViewCalendarColumn dataGridViewColumn = new DataGridViewCalendarColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.ReadOnly = ReadOnly;
            dataGridViewColumn.DefaultCellStyle.Format = Format;
            dataGridViewColumn.DefaultCellStyle.Alignment = Aligment;
            dataGridViewColumn.ValueType = typeof(DateTime);
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddCalender(DataGridView dt, string ColumnName, string Caption, bool ReadOnly, string Format, DataGridViewContentAlignment Aligment, bool Visible)
        {
            DataGridViewCalendarColumn dataGridViewColumn = new DataGridViewCalendarColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.ReadOnly = ReadOnly;
            dataGridViewColumn.DefaultCellStyle.Format = Format;
            dataGridViewColumn.ValueType = typeof(DateTime);
            dataGridViewColumn.DefaultCellStyle.Alignment = Aligment;
            dataGridViewColumn.Visible = Visible;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddCheckBox(DataGridView dt, string ColumnName)
        {
            DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
            col.HeaderText = ColumnName;
            col.Name = ColumnName;
            col.TrueValue = 1;
            col.FalseValue = 0;
            AddCheckBox(dt, col);
        }

        public static void AddCheckBox(DataGridView dt, DataGridViewCheckBoxColumn col)
        {
            dt.Columns.Add(col);
        }

        public static void AddCheckBox(DataGridView dt, string ColumnName, string Caption)
        {
            DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
            col.HeaderText = ColumnName;
            col.Name = ColumnName;
            col.HeaderText = Caption;
            col.TrueValue = 1;
            col.FalseValue = 0;
            AddCheckBox(dt, col);
        }

        public static void AddCheckBox(DataGridView dt, string ColumnName, string Caption, int wdith)
        {
            DataGridViewCheckBoxColumn col = new DataGridViewCheckBoxColumn();
            col.HeaderText = ColumnName;
            col.Name = ColumnName;
            col.HeaderText = Caption;
            col.Width = wdith;
            col.TrueValue = 1;
            col.FalseValue = 0;
            AddCheckBox(dt, col);
        }

        public static void AddComboBox(DataGridView dt, DataGridViewComboBoxColumn col)
        {
            dt.Columns.Add(col);
        }

        public static void AddComboBox(DataGridView dt, string ColumnName, DataTable ds)
        {
            DataGridViewComboBoxColumn dataGridViewColumn = new DataGridViewComboBoxColumn();
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.DataSource = ds;
            dataGridViewColumn.DisplayMember = ColumnName;
            dataGridViewColumn.ValueMember = ColumnName;
            dataGridViewColumn.DataPropertyName = ColumnName;
            dataGridViewColumn.MaxDropDownItems = 20;
            dataGridViewColumn.AutoComplete = true;
            dataGridViewColumn.AutoSizeMode = DataGridViewAutoSizeColumnMode.Fill;
            dataGridViewColumn.DisplayStyle = DataGridViewComboBoxDisplayStyle.Nothing;
            dataGridViewColumn.DisplayStyleForCurrentCellOnly = false;
            dataGridViewColumn.ReadOnly = false;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddComboBox(DataGridView dt, string ColumnName, string[] Items)
        {
            DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn();
            for (int i = 0; i < Items.Length; i++)
            {
                col.Items.Add(Items[i]);
            }
            col.Name = ColumnName;
            col.HeaderText = ColumnName;
            AddComboBox(dt, col);
        }

        public static void AddComboBox(DataGridView dt, string ColumnName, DataTable ds, string DisplayMember, string ValueMember)
        {
            DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn();
            col.Name = ColumnName;
            col.HeaderText = ColumnName;
            col.DataSource = ds;
            col.DisplayMember = DisplayMember;
            col.ValueMember = ValueMember;
            AddComboBox(dt, col);
        }

        public static void AddComboBox(DataGridView dt, string ColumnName, string HeaderText, DataTable ds, string DisplayMember, string ValueMember)
        {
            DataGridViewComboBoxColumn col = new DataGridViewComboBoxColumn();
            col.Name = ColumnName;
            col.HeaderText = HeaderText;
            col.DataSource = ds;
            col.DisplayMember = DisplayMember;
            col.ValueMember = ValueMember;
            AddComboBox(dt, col);
        }

        public static string AddCurrency(object Expression)
        {
            string str = Expression.ToString();
            try
            {
                NumberFormatInfo numberFormat = new CultureInfo("ar-SA", false).NumberFormat;
                numberFormat.NumberDecimalDigits = 0;
                return Convert.ToDouble(str).ToString("N", numberFormat);
            }
            catch (ArgumentException)
            {
                return "0";
            }
            catch (OverflowException)
            {
                return "0";
            }
            catch (FormatException)
            {
                return "0";
            }
        }

        public static void AddIndex(DataGridView dt, string Column)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                dt[Column, i].Value = i + 1;
            }
        }

        public static void AddTextBox(DataGridView dt, string ColumnName)
        {
            DataGridViewTextBoxColumn dataGridViewColumn = new DataGridViewTextBoxColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddTextBox(DataGridView dt, DataGridViewTextBoxColumn col)
        {
            dt.Columns.Add(col);
        }

        public static void AddTextBox(DataGridView dt, string ColumnName, string Caption)
        {
            DataGridViewTextBoxColumn dataGridViewColumn = new DataGridViewTextBoxColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddTextBox(DataGridView dt, string ColumnName, string Caption, int Width)
        {
            DataGridViewTextBoxColumn dataGridViewColumn = new DataGridViewTextBoxColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.Width = Width;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddTextBox(DataGridView dt, string ColumnName, string Caption, int Width, bool ReadOnly)
        {
            DataGridViewTextBoxColumn dataGridViewColumn = new DataGridViewTextBoxColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.Width = Width;
            dataGridViewColumn.ReadOnly = ReadOnly;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddTextBox(DataGridView dt, string ColumnName, string Caption, int Width, bool ReadOnly, string Format)
        {
            DataGridViewTextBoxColumn dataGridViewColumn = new DataGridViewTextBoxColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.Width = Width;
            dataGridViewColumn.ReadOnly = ReadOnly;
            dataGridViewColumn.DefaultCellStyle.Format = Format;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddTextBox(DataGridView dt, string ColumnName, string Caption, int Width, bool ReadOnly, string Format, bool Visible)
        {
            DataGridViewTextBoxColumn dataGridViewColumn = new DataGridViewTextBoxColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.Width = Width;
            dataGridViewColumn.ReadOnly = ReadOnly;
            dataGridViewColumn.DefaultCellStyle.Format = Format;
            dataGridViewColumn.Visible = Visible;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddTextBox(DataGridView dt, string ColumnName, string Caption, int Width, bool ReadOnly, string Format, DataGridViewContentAlignment Alignment)
        {
            DataGridViewTextBoxColumn dataGridViewColumn = new DataGridViewTextBoxColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.Width = Width;
            dataGridViewColumn.ReadOnly = ReadOnly;
            dataGridViewColumn.DefaultCellStyle.Format = Format;
            dataGridViewColumn.DefaultCellStyle.Alignment = Alignment;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static void AddTextBox(DataGridView dt, string ColumnName, string Caption, int Width, bool ReadOnly, string Format, DataGridViewContentAlignment Alignment, int _Type)
        {
            DataGridViewTextBoxColumn dataGridViewColumn = new DataGridViewTextBoxColumn();
            dataGridViewColumn.HeaderText = ColumnName;
            dataGridViewColumn.Name = ColumnName;
            dataGridViewColumn.HeaderText = Caption;
            dataGridViewColumn.Width = Width;
            dataGridViewColumn.ReadOnly = ReadOnly;
            if (_Type == 0)
            {
                dataGridViewColumn.ValueType = typeof(int);
            }
            else if (_Type == 1)
            {
                dataGridViewColumn.ValueType = typeof(double);
            }
            else
            {
                dataGridViewColumn.ValueType = typeof(DateTime);
            }
            dataGridViewColumn.DefaultCellStyle.Format = Format;
            dataGridViewColumn.DefaultCellStyle.Alignment = Alignment;
            dt.Columns.Add(dataGridViewColumn);
        }

        public static int BoolToInt(bool Expression)
        {
            return (Expression ? 1 : 0);
        }

        public static bool Byte_2_Bool(byte a)
        {
            return (a == 1);
        }

        public static string ChangeNum2VnStr(double num)
        {
            string str = num.ToString();
            int length = (str.IndexOf(".") + str.IndexOf(",")) + 1;
            if (length > 0)
            {
                string str2 = str.Substring(0, length);
                string str3 = (str + "00").Substring(length + 1, 2);
                return (Num2VnStr(str2) + " phẩy " + Num2VnStr(str3) + " đồng");
            }
            return (Num2VnStr(str) + " đồng");
        }

        public static int CountCharInString(char vChar, string vString)
        {
            int num = 0;
            for (int i = 0; i < vString.Length; i++)
            {
                if (vChar == vString[i])
                {
                    num++;
                }
            }
            return num;
        }

        public static DataTable CreateTable(DataTable dt, string[] ColumnName)
        {
            for (int i = 0; i < ColumnName.Length; i++)
            {
                dt.Columns.Add(ColumnName[i]);
            }
            return dt;
        }

        public static DataTable DataToTable(DataTable dt, object[] value)
        {
            string message = "";
            if (dt.Columns.Count == value.Length)
            {
                try
                {
                    dt.Rows.Add(value);
                }
                catch (Exception exception)
                {
                    message = exception.Message;
                }
                return dt;
            }
            message = "Gi\x00e1 trị truyền v\x00e0o kh\x00f4ng đ\x00fang với số cột trong Table";
            return dt;
        }

        public static DataTable DeleteDataChecked(DataGridView dt, DataTable table_soure)
        {
            for (int i = 0; i < table_soure.Rows.Count; i++)
            {
                if (dt[0, i].Value.ToString() == "1")
                {
                    table_soure.Rows[i].Delete();
                    i--;
                }
            }
            return table_soure;
        }

        public static string FormatCurrency(object Expression)
        {
            return AddCurrency(RemoveCurrency(Expression.ToString()));
        }

        public static string Get_FirstName(string sFullName)
        {
            string str = "";
            int length = sFullName.LastIndexOf(' ');
            if (length != -1)
            {
                str = sFullName.Substring(0, length);
            }
            return str;
        }

        public static string Get_LastName(string sFullName)
        {
            string str = "";
            int startIndex = sFullName.LastIndexOf(' ');
            if (startIndex != -1)
            {
                str = sFullName.Substring(startIndex, sFullName.Length - startIndex);
            }
            return str;
        }

        public static void GetDataChecked(DataGridView dt, DataTable table_temp)
        {
            int num;
            if (table_temp.Columns.Count == 0)
            {
                string[] columnName = new string[dt.Columns.Count];
                for (num = 0; num < dt.Columns.Count; num++)
                {
                    columnName[num] = dt.Columns[num].Name;
                }
                CreateTable(table_temp, columnName);
            }
            for (num = 0; num < dt.RowCount; num++)
            {
                if (dt[0, num].Value.ToString() == "1")
                {
                    object[] objArray = new object[dt.Columns.Count];
                    for (int i = 0; i < dt.Columns.Count; i++)
                    {
                        objArray[i] = dt[i, num].Value;
                    }
                    DataToTable(table_temp, objArray);
                }
            }
        }

        public static string GetFirstWord(string studentName)
        {
            string str = "";
            if (studentName.Trim().Length == 0)
            {
                return "";
            }
            string[] strArray = studentName.Split(new char[] { ' ' });
            foreach (string str2 in strArray)
            {
                if (str2.Length > 0)
                {
                    str = str + str2.Substring(0, 1);
                }
            }
            return str;
        }

        public static DataTable GetValueChecked(DataGridView dt, DataTable table_temp)
        {
            int num;
            if (table_temp.Columns.Count == 0)
            {
                string[] columnName = new string[dt.Columns.Count];
                for (num = 0; num < dt.Columns.Count; num++)
                {
                    columnName[num] = dt.Columns[num].Name;
                }
                CreateTable(table_temp, columnName);
            }
            for (num = 0; num < dt.RowCount; num++)
            {
                if (dt[0, num].Value.ToString() == "1")
                {
                    byte num2 = 1;
                    for (int i = 0; i < table_temp.Rows.Count; i++)
                    {
                        DataRow row = table_temp.Rows[i];
                        if (row[1].ToString() == dt[1, num].Value.ToString())
                        {
                            num2 = 0;
                        }
                    }
                    if (num2 == 1)
                    {
                        if (IsString(dt[6, num].Value.ToString()))
                        {
                            if (int.Parse(dt[6, num].Value.ToString()) > 0)
                            {
                                if (int.Parse(dt[6, num].Value.ToString()) < int.Parse(dt[3, num].Value.ToString()))
                                {
                                    object[] objArray = new object[dt.Columns.Count];
                                    for (int j = 0; j < dt.Columns.Count; j++)
                                    {
                                        objArray[j] = dt[j, num].Value;
                                    }
                                    DataToTable(table_temp, objArray);
                                }
                                else
                                {
                                    MessageBox.Show("Xin h\x00e3y nhập số lượng mua < số lượng c\x00f2n", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                                }
                            }
                            else
                            {
                                MessageBox.Show("Xin h\x00e3y nhập số lượng mua > 0", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Xin h\x00e3y nhập số lượng mua!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                        }
                    }
                    else
                    {
                        MessageBox.Show("Vật tư n\x00e0y bạn d\x00e3 chọn rồi!", "Th\x00f4ng b\x00e1o", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                    }
                }
            }
            return table_temp;
        }

        public static string Insert(string input, string value, int startIndex, bool rightToLeft)
        {
            if (rightToLeft)
            {
                if (startIndex > input.Length)
                {
                    startIndex = 0;
                }
                else
                {
                    startIndex = input.Length - startIndex;
                }
            }
            else if (startIndex > input.Length)
            {
                startIndex = input.Length;
            }
            return input.Insert(startIndex, value);
        }

        public static bool IsAddressAvailable(string address)
        {
            Ping ping = new Ping();
            try
            {
                return (ping.Send(address, 100).Status == IPStatus.Success);
            }
            catch
            {
                return false;
            }
        }

        public static bool IsBirthDay(string vDate)
        {
            if (!IsNumeric(vDate))
            {
                string[] strArray = new string[] { "", "", "" };
                if (vDate.IndexOf('/') == 0)
                {
                    return false;
                }
                int num = CountCharInString('/', vDate);
                if (num == 1)
                {
                    strArray = vDate.Split(new char[] { '/' });
                    if (!IsNumeric(strArray[0]) | !IsNumeric(strArray[1]))
                    {
                        return false;
                    }
                    num = Convert.ToInt32(strArray[0]);
                    if ((num < 0) | (num > 12))
                    {
                        return false;
                    }
                    if (Convert.ToInt32(strArray[1]) < 0)
                    {
                        return false;
                    }
                }
                else
                {
                    if (num != 2)
                    {
                        return false;
                    }
                    strArray = vDate.Split(new char[] { '/' });
                    if ((!IsNumeric(strArray[0]) | !IsNumeric(strArray[1])) | !IsNumeric(strArray[2]))
                    {
                        return false;
                    }
                    if (Convert.ToInt32(strArray[2]) < 0)
                    {
                        return false;
                    }
                    num = Convert.ToInt32(strArray[1]);
                    int num2 = num;
                    if ((num < 0) | (num > 12))
                    {
                        return false;
                    }
                    num = Convert.ToInt32(strArray[0]);
                    if ((num < 0) | (num > 0x1f))
                    {
                        return false;
                    }
                    if (((num2 <= 7) & ((num2 % 2) == 0)) & (num > 30))
                    {
                        return false;
                    }
                    if (((num2 > 8) & ((num2 % 2) != 0)) & (num > 30))
                    {
                        return false;
                    }
                    if (num2 == 2)
                    {
                        if ((Convert.ToInt32(strArray[2]) % 4) == 0)
                        {
                            if (num > 0x1d)
                            {
                                return false;
                            }
                        }
                        else if (num > 0x1c)
                        {
                            return false;
                        }
                    }
                }
            }
            return true;
        }

        public static bool IsDate(string vDate)
        {
            string[] strArray = new string[] { "", "", "" };
            if (vDate.IndexOf('/') == 0)
            {
                return false;
            }
            if (CountCharInString('/', vDate) != 2)
            {
                return false;
            }
            strArray = vDate.Split(new char[] { '/' });
            if ((!IsNumeric(strArray[0]) | !IsNumeric(strArray[1])) | !IsNumeric(strArray[2]))
            {
                return false;
            }
            if (Convert.ToInt32(strArray[2]) < 0)
            {
                return false;
            }
            int num = Convert.ToInt32(strArray[1]);
            int num2 = num;
            if ((num < 0) | (num > 12))
            {
                return false;
            }
            num = Convert.ToInt32(strArray[0]);
            if ((num < 0) | (num > 0x1f))
            {
                return false;
            }
            if (((num2 <= 7) & ((num2 % 2) == 0)) & (num > 30))
            {
                return false;
            }
            if (((num2 > 8) & ((num2 % 2) != 0)) & (num > 30))
            {
                return false;
            }
            if (num2 == 2)
            {
                if ((Convert.ToInt32(strArray[2]) % 4) == 0)
                {
                    if (num > 0x1d)
                    {
                        return false;
                    }
                }
                else if (num > 0x1c)
                {
                    return false;
                }
            }
            return true;
        }

        public static bool IsNumeric(object Expression)
        {
            double num;
            return double.TryParse(Convert.ToString(Expression), NumberStyles.Any, (IFormatProvider) NumberFormatInfo.InvariantInfo, out num);
        }

        public static bool IsString(string str)
        {
            if (str.Length != 0)
            {
                try
                {
                    double result = 0.0;
                    return double.TryParse(str, NumberStyles.Any, (IFormatProvider) NumberFormatInfo.CurrentInfo, out result);
                }
                catch
                {
                    return false;
                }
            }
            return false;
        }

        public static bool IsValidEmailAddress(string sEmail)
        {
            if (sEmail != null)
            {
                int index = sEmail.IndexOf('@');
                int num2 = sEmail.LastIndexOf('@');
                if (((index > 0) && (num2 == index)) && (index < (sEmail.Length - 1)))
                {
                    bool flag = Regex.IsMatch(sEmail, @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
                    if (flag)
                    {
                        if (sEmail[sEmail.Length - 1] == '.')
                        {
                            flag = false;
                        }
                        if (sEmail.IndexOf("..") != -1)
                        {
                            flag = false;
                        }
                        for (int i = 0; i < sEmail.Length; i++)
                        {
                            if (((((((sEmail[i] < 'A') || (sEmail[i] > 'Z')) & ((sEmail[i] < 'a') || (sEmail[i] > 'z'))) & ((sEmail[i] < '0') || (sEmail[i] > '9'))) & (sEmail[i] != '@')) & (sEmail[i] != '.')) & (sEmail[i] != '_'))
                            {
                                return false;
                            }
                        }
                    }
                    return flag;
                }
            }
            return false;
        }

        public static string Num2VnStr(string num)
        {
            string str = "";
            if (num.Equals("0"))
            {
                str = "kh\x00f4ng";
            }
            else
            {
                num = RemoveNumberZero(num);
                char ch = num[0];
                if (ch.ToString().Equals("-"))
                {
                    str = "\x00e2m ";
                    num = num.Substring(1, num.Length - 1);
                }
                ch = num[0];
                if (ch.ToString().Equals("+"))
                {
                    num = num.Substring(1, num.Length - 1);
                }
                string[] strArray = new string[] { "kh\x00f4ng", "một", "hai", "ba", "bốn", "năm", "s\x00e1u", "bảy", "t\x00e1m", "ch\x00edn" };
                string[] strArray2 = new string[] { "", "ng\x00e0n", "triệu", "tỷ" };
                string str3 = num;
                int length = str3.Length;
                for (int i = 0; i < length; i++)
                {
                    string str2 = "";
                    int num5 = ((length - i) - 1) % 3;
                    int index = int.Parse(str3.Substring(i, 1));
                    switch (index)
                    {
                        case 0:
                            strArray[0] = "";
                            if ((num5 != 0) || !length.Equals(1))
                            {
                                goto Label_029F;
                            }
                            strArray[0] = "kh\x00f4ng";
                            goto Label_032C;

                        case 1:
                            if ((num5 != 0) || (i <= 0))
                            {
                                goto Label_01F5;
                            }
                            if (!(str3.Substring(i - 1, 1) != "1") || !(str3.Substring(i - 1, 1) != "0"))
                            {
                                break;
                            }
                            strArray[1] = "mốt";
                            goto Label_032C;

                        case 5:
                            if ((num5 != 0) || (i == 0))
                            {
                                goto Label_0263;
                            }
                            if (str3.Substring(i - 1, 1) != "0")
                            {
                                strArray[5] = "lăm";
                            }
                            else
                            {
                                strArray[5] = "năm";
                            }
                            goto Label_032C;

                        default:
                            goto Label_032C;
                    }
                    strArray[1] = "một";
                    goto Label_032C;
                Label_01F5:
                    if (num5 == 1)
                    {
                        strArray[1] = "mười";
                    }
                    else
                    {
                        strArray[1] = "một";
                    }
                    goto Label_032C;
                Label_0263:
                    strArray[5] = "năm";
                    goto Label_032C;
                Label_029F:
                    if (num5 == 1)
                    {
                        if (str3.Substring(i + 1, 1) != "0")
                        {
                            strArray[0] = "lẻ";
                        }
                    }
                    else if ((num5 == 2) && ((str3.Substring(i + 1, 1) != "0") || (str3.Substring(i + 2, 1) != "0")))
                    {
                        strArray[0] = "kh\x00f4ng";
                    }
                Label_032C:
                    switch (num5)
                    {
                        case 1:
                            if ((str3.Substring(i, 1) != "1") && (str3.Substring(i, 1) != "0"))
                            {
                                str2 = "mươi";
                            }
                            goto Label_0490;

                        case 2:
                            if (i != 0)
                            {
                                break;
                            }
                            str2 = "trăm";
                            goto Label_0490;

                        default:
                        {
                            int num2 = (length - i) / 3;
                            if (num2 > 3)
                            {
                                num2 = num2 % 3;
                            }
                            if (i > 2)
                            {
                                if ((((str3.Substring(i - 2, 1) != "0") || (str3.Substring(i - 1, 1) != "0")) || (str3.Substring(i, 1) != "0")) || (i == str3.Length))
                                {
                                    str2 = strArray2[num2];
                                }
                            }
                            else
                            {
                                str2 = strArray2[num2];
                            }
                            goto Label_0490;
                        }
                    }
                    if (((str3.Substring(i, 1) != "0") || (str3.Substring(i + 1, 1) != "0")) || (str3.Substring(i + 2, 1) != "0"))
                    {
                        str2 = "trăm";
                    }
                Label_0490:
                    if (strArray[index] == "")
                    {
                        str = str.Trim() + " " + str2;
                    }
                    else
                    {
                        str = str.Trim() + " " + strArray[index] + " " + str2;
                    }
                }
            }
            return str.Trim();
        }

        private static string NumToText(string Expression)
        {
            NumberFormatInfo numberFormat;
            string str4;
            int num2;
            string str = "";
            string str2 = "";
            try
            {
                numberFormat = CultureInfo.CurrentCulture.NumberFormat;
                Expression = Convert.ToInt64(Expression).ToString("##,##0");
            }
            catch (ArgumentException exception)
            {
                return exception.Message;
            }
            catch (OverflowException exception2)
            {
                return exception2.Message;
            }
            catch (FormatException exception3)
            {
                return exception3.Message;
            }
            string[] strArray = Expression.Split(new char[] { Convert.ToChar(numberFormat.NumberGroupSeparator) });
            int index = 0;
            while (index < (strArray.Length - 3))
            {
                str4 = strArray[index];
                if (!str4.Equals("000"))
                {
                    num2 = 0;
                    while (num2 < str4.Length)
                    {
                        if (num2 < (str4.Length - 1))
                        {
                            if ((int.Parse(Convert.ToString(str4[num2])) == 1) && (((str4.Length - num2) - 1) == 1))
                            {
                                str = str + " " + outputpostring((str4.Length - num2) - 1, str4[num2], str4[num2 + 1]);
                            }
                            else
                            {
                                str = str + " " + outputnumberstring(str4[num2], '0', num2, str4.Length) + " " + outputpostring((str4.Length - num2) - 1, str4[num2], str4[num2 + 1]);
                            }
                        }
                        else if (str4.Length == 1)
                        {
                            str = str + " " + outputnumberstring(str4[num2], '0', num2, str4.Length) + " " + outputpostring((str4.Length - num2) - 1, str4[num2], '0');
                        }
                        else
                        {
                            str = str + " " + outputnumberstring(str4[num2], str4[num2 - 1], num2, str4.Length) + " " + outputpostring((str4.Length - num2) - 1, str4[num2], '0');
                        }
                        num2++;
                    }
                    str = str.Trim() + " " + outputgrouptring((strArray.Length - index) - 1);
                }
                index++;
            }
            while (index < strArray.Length)
            {
                try
                {
                    str4 = strArray[index];
                    if (!str4.Equals("000"))
                    {
                        for (num2 = 0; num2 < str4.Length; num2++)
                        {
                            if (num2 < (str4.Length - 1))
                            {
                                if ((int.Parse(Convert.ToString(str4[num2])) == 1) && (((str4.Length - num2) - 1) == 1))
                                {
                                    str2 = str2 + " " + outputpostring((str4.Length - num2) - 1, str4[num2], str4[num2 + 1]);
                                }
                                else
                                {
                                    str2 = str2 + " " + outputnumberstring(str4[num2], '0', num2, str4.Length) + " " + outputpostring((str4.Length - num2) - 1, str4[num2], str4[num2 + 1]);
                                }
                            }
                            else if (str4.Length == 1)
                            {
                                str2 = str2 + " " + outputnumberstring(str4[num2], '0', num2, str4.Length) + " " + outputpostring((str4.Length - num2) - 1, str4[num2], '0');
                            }
                            else
                            {
                                str2 = str2 + " " + outputnumberstring(str4[num2], str4[num2 - 1], num2, str4.Length) + " " + outputpostring((str4.Length - num2) - 1, str4[num2], '0');
                            }
                        }
                        str2 = str2.Trim() + " " + outputgrouptring((strArray.Length - index) - 1);
                    }
                }
                catch (Exception)
                {
                    return null;
                }
                index++;
            }
            return (str + (str.Equals("") ? " " : " tỷ ") + str2).Trim();
        }

        private static string outputgrouptring(int group)
        {
            switch (group)
            {
                case 0:
                case 3:
                    return "";

                case 1:
                case 4:
                    return "ngh\x00ecn";

                case 2:
                case 5:
                    return "triệu";
            }
            return "";
        }

        private static string outputnumberstring(char num, char prenum, int pos, int length)
        {
            switch (int.Parse(Convert.ToString(num)))
            {
                case 0:
                    if (pos < 1)
                    {
                        return "kh\x00f4ng";
                    }
                    return "";

                case 1:
                    if ((pos != (length - 1)) || (int.Parse(Convert.ToString(prenum)) <= 1))
                    {
                        return "một";
                    }
                    return "mốt";

                case 2:
                    return "hai";

                case 3:
                    return "ba";

                case 4:
                    return "bốn";

                case 5:
                    if ((pos != (length - 1)) || prenum.Equals('0'))
                    {
                        return "năm";
                    }
                    return "lăm";

                case 6:
                    return "s\x00e1u";

                case 7:
                    return "bảy";

                case 8:
                    return "t\x00e1m";

                case 9:
                    return "ch\x00edn";
            }
            return "";
        }

        private static string outputpostring(int pos, char num, char nextnum)
        {
            switch (pos)
            {
                case 0:
                    return "";

                case 1:
                    if (int.Parse(Convert.ToString(num)) != 1)
                    {
                        if ((int.Parse(Convert.ToString(num)) == 0) && (int.Parse(Convert.ToString(nextnum)) == 0))
                        {
                            return "";
                        }
                        if ((int.Parse(Convert.ToString(num)) == 0) && (int.Parse(Convert.ToString(nextnum)) != 0))
                        {
                            return "lẻ";
                        }
                        return "mươi";
                    }
                    return "mười";

                case 2:
                    return "trăm";
            }
            return "";
        }

        public static string RejectMarks(string text)
        {
            if (text.Length != 0)
            {
                string[] strArray = new string[] { "a|(\x00e1|ả|\x00e0|ạ|\x00e3|ă|ắ|ẳ|ằ|ặ|ẵ|\x00e2|ấ|ẩ|ầ|ậ|ẫ)", "o|(\x00f3|ỏ|\x00f2|ọ|\x00f5|\x00f4|ố|ổ|ồ|ộ|ỗ|ơ|ớ|ở|ờ|ợ|ỡ)", "e|(\x00e9|\x00e8|ẻ|ẹ|ẽ|\x00ea|ế|ề|ể|ệ|ễ)", "u|(\x00fa|\x00f9|ủ|ụ|ũ|ư|ứ|ừ|ử|ự|ữ)", "i|(\x00ed|\x00ec|ỉ|ị|ĩ)", "y|(\x00fd|ỳ|ỷ|ỵ|ỹ)", "d|đ" };
                for (int i = 0; i < strArray.Length; i++)
                {
                    char newChar = strArray[i][0];
                    MatchCollection matchs = Regex.Matches(text, strArray[i]);
                    foreach (Match match in matchs)
                    {
                        text = text.Replace(match.Value[0], newChar);
                    }
                }
            }
            return text;
        }

        public static string Remove(string input, int startIndex, int count, bool rightToLeft)
        {
            string str;
            try
            {
                if (rightToLeft)
                {
                    if (startIndex > input.Length)
                    {
                        startIndex = 0;
                    }
                    else
                    {
                        startIndex = (input.Length - startIndex) - count;
                    }
                }
                else if (startIndex > input.Length)
                {
                    startIndex = input.Length;
                }
                startIndex = (startIndex < 0) ? 0 : startIndex;
                if (count > input.Length)
                {
                    count = input.Length;
                }
                else
                {
                    count = (count < 0) ? 0 : count;
                }
                str = input.Remove(startIndex, count);
            }
            catch (Exception exception)
            {
                throw exception;
            }
            return str;
        }

        public static string RemoveCurrency(object Expression)
        {
            return Expression.ToString().Replace(",", "");
        }

        public static string RemoveNumberZero(string pnum)
        {
            char ch;
            int startIndex = 0;
        Label_000B:
            ch = pnum[startIndex];
            if (ch.Equals('0'))
            {
                startIndex++;
                goto Label_000B;
            }
            return pnum.Substring(startIndex, pnum.Length - startIndex);
        }

        public static void RemoveRowsChecked(DataGridView dgv)
        {
            for (int i = 0; i < dgv.RowCount; i++)
            {
                string str = "0";
                try
                {
                    str = dgv[0, i].Value.ToString();
                }
                catch
                {
                    break;
                }
                if (str == "1")
                {
                    dgv.Rows.RemoveAt(i);
                    i--;
                }
            }
        }

        public static void RemoveRowsChecked(DataGridView dgv, int IsSave)
        {
            for (int i = 0; i < dgv.RowCount; i++)
            {
                string str = "0";
                try
                {
                    str = dgv["Chon", i].Value.ToString();
                }
                catch
                {
                }
                if ((str == "1") & (int.Parse(dgv["IsSave", i].Value.ToString()) == IsSave))
                {
                    dgv.Rows.RemoveAt(i);
                    i--;
                }
            }
        }

        public static string Replace(string input, string oldValue, string newValue, bool matchCase)
        {
            RegexOptions none = RegexOptions.None;
            if (!matchCase)
            {
                none = RegexOptions.IgnoreCase;
            }
            input = new Regex(oldValue, none).Replace(input, newValue);
            return input;
        }

        public static string SignSoft()
        {
            return SignSoft(MyAssembly.AssemblyTitle);
        }

        public static string SignSoft(string softname)
        {
            return GetFirstWord(RejectMarks(softname)).ToUpper();
        }

        public static double Substract(DataGridView dt, int ColumnIndex, double NumLeave)
        {
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                NumLeave -= double.Parse(dt[ColumnIndex, i].Value.ToString());
            }
            return NumLeave;
        }

        public static string TableToComboBox(ComboBox combo, DataTable table, string Value, string Key)
        {
            string message = "";
            try
            {
                combo.DataSource = table;
                combo.DisplayMember = Value;
                combo.ValueMember = Key;
            }
            catch (Exception exception)
            {
                message = exception.Message;
            }
            return message;
        }

        public static string TableToListBox(ListBox listbox, DataTable table, string Value, string Key)
        {
            string message = "";
            try
            {
                listbox.DataSource = table;
                listbox.DisplayMember = Value;
                listbox.ValueMember = Key;
            }
            catch (Exception exception)
            {
                message = exception.Message;
            }
            return message;
        }

        public static DateTime ToDate(object Expression)
        {
            DateTime now = new DateTime();
            now = DateTime.Now;
            if (Expression != null)
            {
                string vDate = Expression.ToString();
                if (IsDate(vDate))
                {
                    string[] strArray = new string[] { "0", "0", "0" };
                    strArray = vDate.Split(new char[] { '/' });
                    now = new DateTime(int.Parse(strArray[2]), int.Parse(strArray[1]), int.Parse(strArray[0]));
                }
            }
            return now;
        }

        public static double ToDouble(object expression)
        {
            return Convert.ToDouble(RemoveCurrency(expression.ToString()));
        }

        public static int ToInt(object expression)
        {
            return Convert.ToInt32(RemoveCurrency(expression.ToString()));
        }

        public static double Total(DataGridView dt, string ColumnName)
        {
            double num = 0.0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                num += Convert.ToDouble(dt[ColumnName, i].Value);
            }
            return num;
        }

        public static double Total(DataGridView dt, string ColumnName, bool Visible)
        {
            double num = 0.0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Visible)
                {
                    if (dt[ColumnName, i].Visible)
                    {
                        num += Convert.ToDouble(dt[ColumnName, i].Value.ToString());
                    }
                }
                else
                {
                    num += Convert.ToDouble(dt[ColumnName, i].Value.ToString());
                }
            }
            return num;
        }

        public static double Total(DataGridView dt, string ColumnName, int Value)
        {
            double num = 0.0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToInt32(dt[ColumnName, i].Value) == Value)
                {
                    num += Convert.ToDouble(dt[ColumnName, i].Value.ToString());
                }
            }
            return num;
        }

        public static double TotalOrder(DataGridView dt, string ColumnName, int Value)
        {
            double num = 0.0;
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (Convert.ToInt32((dt[ColumnName, i].Value == "") ? 0 : dt[ColumnName, i].Value) != Value)
                {
                    num += Convert.ToDouble(dt[ColumnName, i].Value.ToString());
                }
            }
            return num;
        }

        public static string ToText(decimal Expression)
        {
            return ToText(Expression.ToString());
        }

        public static string ToText(double Expression)
        {
            return ToText(Expression.ToString());
        }

        public static string ToText(int Expression)
        {
            return ToText(Expression.ToString());
        }

        public static string ToText(object Expression)
        {
            return ToText(Expression.ToString());
        }

        public static string ToText(string Expression)
        {
            return ToText(Expression, EnumCurrency.VND);
        }

        public static string ToText(string Expression, EnumCurrency cur)
        {
            string str;
            char ch;
            if (cur == EnumCurrency.USD)
            {
                return USD(Expression);
            }
            NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat;
            Expression = Expression.Replace(numberFormat.NumberGroupSeparator, "");
            if (!IsNumeric(Expression))
            {
                return "Kh\x00f4ng đọc được số";
            }
            string[] strArray = Expression.Split(new char[] { Convert.ToChar(numberFormat.NumberDecimalSeparator) });
            if (_Currency == "VND")
            {
                Expression = NumToText(strArray[0]);
                if (strArray.Length > 1)
                {
                    str = strArray[1];
                    if (str.Length >= 3)
                    {
                        if (str[0] == '0')
                        {
                            Expression = Expression + " " + _currencySymbol + " phẩy kh\x00f4ng ";
                            if (str[1] == '0')
                            {
                                ch = str[2];
                                Expression = Expression + "kh\x00f4ng " + NumToText(ch.ToString());
                            }
                            else
                            {
                                Expression = Expression + NumToText(str.Substring(1, 2));
                            }
                        }
                        else
                        {
                            Expression = Expression + " phẩy " + NumToText(str.Substring(0, 3));
                        }
                    }
                    else if (str.Length == 2)
                    {
                        if (str[0] == '0')
                        {
                            Expression = Expression + " phẩy kh\x00f4ng ";
                            if (str[1] == '0')
                            {
                                ch = str[1];
                                Expression = Expression + NumToText(ch.ToString());
                            }
                            else
                            {
                                Expression = Expression + NumToText(str.Substring(1, 1));
                            }
                        }
                        else
                        {
                            Expression = Expression + " " + _currencySymbol + " phẩy " + NumToText(str.Substring(0, 2));
                        }
                    }
                    else
                    {
                        string[] strArray2 = new string[5];
                        strArray2[0] = Expression;
                        strArray2[1] = " ";
                        strArray2[2] = _currencySymbol;
                        strArray2[3] = " phẩy ";
                        ch = str[0];
                        strArray2[4] = NumToText(ch.ToString());
                        Expression = string.Concat(strArray2);
                    }
                }
                else
                {
                    Expression = Expression + " " + _currencySymbol;
                }
                if (Expression.Length > 1)
                {
                    ch = Expression[0];
                    Expression = ch.ToString().ToUpper() + Expression.Substring(1);
                }
                return Expression;
            }
            Expression = NumToText(strArray[0]);
            if (strArray.Length > 1)
            {
                str = strArray[1];
                if (str.Length >= 3)
                {
                    if (str[0] == '0')
                    {
                        Expression = Expression + " " + _currencySymbol + " v\x00e0 lẻ ";
                        if (str[1] == '0')
                        {
                            ch = str[2];
                            Expression = Expression + "kh\x00f4ng " + NumToText(ch.ToString());
                        }
                        else
                        {
                            Expression = Expression + NumToText(str.Substring(1, 2));
                        }
                    }
                    else
                    {
                        Expression = Expression + " " + _currencySymbol + " v\x00e0 " + NumToText(str.Substring(0, 3));
                    }
                }
                else if (str.Length == 2)
                {
                    if (str[0] == '0')
                    {
                        Expression = Expression + " " + _currencySymbol + " v\x00e0 lẻ ";
                        if (str[1] == '0')
                        {
                            ch = str[1];
                            Expression = Expression + NumToText(ch.ToString());
                        }
                        else
                        {
                            Expression = Expression + NumToText(str.Substring(1, 1));
                        }
                    }
                    else
                    {
                        Expression = Expression + " " + _currencySymbol + " v\x00e0 " + NumToText(str.Substring(0, 2));
                    }
                }
                else
                {
                    Expression = Expression + " " + _currencySymbol + " v\x00e0 " + NumToText(str.Substring(0, 1));
                }
                Expression = Expression + " " + _UnitSecond;
            }
            else
            {
                Expression = Expression + " " + _currencySymbol;
            }
            if (Expression.Length > 1)
            {
                ch = Expression[0];
                Expression = ch.ToString().ToUpper() + Expression.Substring(1);
            }
            return Expression;
        }

        public static string ToTitleCase(string str)
        {
            if (str.Length == 0)
            {
                return str;
            }
            str = str.ToLower();
            char[] chArray = str.ToCharArray();
            chArray[0] = char.ToUpper(chArray[0]);
            foreach (Match match in Regex.Matches(str, @"(\s\S)"))
            {
                chArray[match.Index + 1] = match.Value.ToUpper().Trim()[0];
            }
            return new string(chArray);
        }

        public static string ToToggleCase(string str)
        {
            string str2 = "";
            foreach (char ch in str)
            {
                string str3 = ch.ToString();
                if (str3 == str3.ToLower())
                {
                    str2 = str2 + str3.ToUpper();
                }
                else
                {
                    str2 = str2 + str3.ToLower();
                }
            }
            return str2;
        }

        private static string USD(decimal AMT)
        {
            NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat;
            string str = null;
            string str2 = null;
            string str3 = null;
            string str4 = null;
            int index = 0;
            long num3 = 0L;
            long num4 = 0L;
            long num5 = 0L;
            long num6 = 0L;
            if (AMT == 0M)
            {
                str = "None";
            }
            else
            {
                string[] strArray = new string[] { 
                    "None", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", 
                    "sixteen", "seventeen", "eighteen", "nineteen"
                 };
                string[] strArray2 = new string[] { "None", "None", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety" };
                string[] strArray3 = new string[] { "None", "billion", "million", "thousand", "dollars", "cents" };
                if (AMT < 0M)
                {
                    str = "Minus" + new string(' ', 1);
                }
                else
                {
                    str = new string(' ', 0);
                }
                str2 = Math.Abs(AMT).ToString("############.00");
                string str5 = new string(' ', 12) + str2;
                str2 = str5.Substring(str5.Length - 15);
                string str6 = numberFormat.NumberDecimalSeparator + "00";
                for (index = 1; index <= 5; index++)
                {
                    str3 = str2.Substring(((index * 3) - 2) - 1, 3);
                    if (str3 != new string(' ', 3))
                    {
                        if (str3 == "000")
                        {
                            if ((index == 4) && (Math.Abs(AMT) > 1M))
                            {
                                str4 = "dollars" + new string(' ', 1);
                            }
                            else
                            {
                                str4 = new string(' ', 0);
                            }
                        }
                        else if (str3 == str6)
                        {
                            str4 = "only";
                        }
                        else
                        {
                            num4 = Convert.ToInt64(Double.Parse(str3.Substring(0, 1)));
                            num5 = Convert.ToInt64(Double.Parse(str3.Substring(2, 1)));
                            num6 = Convert.ToInt64(Double.Parse(str3.Substring(str3.Length - 1)));
                            num3 = Convert.ToInt64(Double.Parse(str3.Substring(str3.Length - 2)));
                            if (num4 == 0L)
                            {
                                str4 = new string(' ', 0);
                            }
                            else
                            {
                                str4 = strArray[(int) ((IntPtr) num4)] + new string(' ', 1) + "hundred" + new string(' ', 1);
                                if ((num3 > 0L) & (num3 < 0x15L))
                                {
                                    str4 = str4 + "and" + new string(' ', 1);
                                }
                            }
                            if ((index == 5) && (Math.Abs(AMT) > 1M))
                            {
                                str4 = "and" + new string(' ', 1) + str4;
                            }
                            if ((num3 < 20L) & (num3 > 0L))
                            {
                                str4 = str4 + strArray[(int) ((IntPtr) num3)] + new string(' ', 1);
                            }
                            else if (num3 >= 20L)
                            {
                                str4 = str4 + strArray2[(int) ((IntPtr) num5)] + new string(' ', 1);
                                if (num6 > 0L)
                                {
                                    str4 = str4 + strArray[(int) ((IntPtr) num6)] + new string(' ', 1);
                                }
                            }
                            str4 = str4 + strArray3[index] + new string(' ', 1);
                        }
                        str = str + str4;
                    }
                }
            }
            return (str.Substring(0, 1).ToUpper() + str.Substring(2));
        }

        private static string USD(string Expression)
        {
            NumberFormatInfo numberFormat = CultureInfo.CurrentCulture.NumberFormat;
            Expression = Expression.Replace(numberFormat.NumberGroupSeparator, "");
            if (!IsNumeric(Expression))
            {
                return "None";
            }
            return USD(Convert.ToDecimal(Expression));
        }

        public static string Currency
        {
            get
            {
                return _Currency;
            }
            set
            {
                _Currency = value;
            }
        }

        public static string CurrencySymbol
        {
            get
            {
                return _currencySymbol;
            }
            set
            {
                _currencySymbol = value;
            }
        }

        public static string UnitSecond
        {
            get
            {
                return _UnitSecond;
            }
            set
            {
                _UnitSecond = value;
            }
        }
    }
}

